//
//  MessageModel.m
//  ProjectforHDX
//
//  Created by Jaesun on 16/7/8.
//  Copyright © 2016年 H.DX. All rights reserved.
//

#import "MessageModel.h"

@implementation MessageModel

-(void)encodeWithCoder:(NSCoder *)aCoder{
    
    NSArray *names = [NSArray gethdxProperties:[self class]];
    for (NSString *name in names) {
        id value = [self valueForKey:name];
        [aCoder encodeObject:value  forKey:name];
    }
}


-(id)initWithCoder:(NSCoder *)aDecoder{
    self = [super init];
    if (self) {
        
        //获取所有属性 ，遍历 给属性赋值
        NSArray *names = [NSArray gethdxProperties:[self class]];
        for (NSString *name in names) {
            [self  setValue:[aDecoder decodeObjectForKey:name] forKey:name];
            
        }
        
    }
    return self;
}

-(void)setAttributes:(NSDictionary *)infoDic{
    
    [super setAttributes:infoDic];
    //获取所有属性 ，遍历 给属性赋值
    NSArray *names = [NSArray gethdxProperties:[self class]];
    for (NSString *name in names) {
        [self  setValue:[infoDic objectForKey:name] forKey:name];
        
    }
    
}

// 返回字典数据的key与model属性不一致取值
//- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
////    if ([key isEqualToString:@"addTime"]) {
////        self.addTimeStr = value;
////    }
////    else if ([key isEqualToString:@"type"]) {
////        self.typeStr = value;
//    }
//}


@end
